home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 26.zip
/
BS1 part 26
/
C for beginners.adf
/
source
/
write-read.c
< prev
Wrap
C/C++ Source or Header
|
1978-01-17
|
1KB
|
44 lines
/* write-read.c 23.4 */
#define NUMBER (sizeof(data)/sizeof(double))
double data[] =
{
1.5, 2.0, 3.14159265, 2.718281828,
};
main()
{
int handle, dummy = 0, i, actual;
double data2[NUMBER];
char filename[81];
printf("Please input filename!\n");
scanf("%80s", filename);
handle = creat(filename, dummy); /* Create new */
if(handle != -1) /* Everything OK? */
{
actual = write(handle, data, sizeof(data));
printf("Desired %d Bytes, Actual %d Bytes\n",
sizeof(data), actual);
close(handle);
}
else
printf("Error during creation of %s\n", filename);
handle = open(filename, 0, dummy); /* Read */
if(handle != -1) /* Everything OK? */
{
actual = read(handle, data2, sizeof(data));
printf("Desired %d Bytes, Actual %d Bytes\n",
sizeof(data), actual);
close(handle);
}
else
printf("Error during opening of %s\n", filename);
for(i=0; i < NUMBER; i++)
printf("%.8lf ", data2[i]);
printf("\nThat's all!\n");
}